<template>
    <a-table :columns="columns" :data-source="figures" class="components-table-demo-nested">
        <a-table
                slot="expandedRowRender"
                slot-scope="record, index, indent, expanded"
                :columns="innerColumns"
                :data-source="record.innerData"
                :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        >
            <!--<span slot="status" slot-scope="text"> <a-badge status="success" />Finished </span>-->
            <template slot="purchasingNum">
                <a-input-number     @change="change" />
            </template>
            <a-button type="primary">确定</a-button>
            <!--<span slot="operation" slot-scope="text" class="table-operation">--><!--</span>-->
        </a-table>
    </a-table>
</template>
<script>
    const columns = [
        { title: '姓名', dataIndex: 'name' },
        { title: 'Platform', dataIndex: 'platform' },
        { title: 'Version', dataIndex: 'version'},
        { title: 'Upgraded', dataIndex: 'upgradeNum' },
        { title: 'Creator', dataIndex: 'creator' },
        { title: 'Date', dataIndex: 'createdAt' },
    ];

    const figures = [];
    for (let i = 0; i < 3; ++i) {
        figures.push({
            key: i,
            name: 'Screem',
            platform: 'iOS',
            version: '10.3.4.5654',
            upgradeNum: i,
            creator: 'Jack',
            createdAt: '2014-12-24 23:12:00',
            innerData:[
                {key:i*3+1,date:'2014-12-24 23:12:00',name:i*2+1,upgradeNum:'shanghai113',purchasingNum:''},
                {key:i*4+2,date:'2014-12-24 23:12:00',name:i*3+1,upgradeNum:'shanghai113',purchasingNum:''},
                {key:i*5+3,date:'2014-12-24 23:12:00',name:i*4+1,upgradeNum:'shanghai113',purchasingNum:''}
                ]
        });
    }

    const innerColumns = [
        { title: 'Date', dataIndex: 'date', key: 'date' },
        { title: 'Name', dataIndex: 'name', key: 'name' },
        // { title: 'Status', key: 'state', scopedSlots: { customRender: 'status' } },
        { title: 'UpgradeNum', dataIndex: 'upgradeNum', key: 'upgradeNum' },
        {title: '采购数量', dataIndex: 'purchasingNum', key: 'purchasingNum', scopedSlots: { customRender: 'purchasingNum' },
        }
    ];


    // const innerData = [];
    // for (let i = 0; i < 9; ++i) {
    //     innerData.push({
    //         key: i,
    //         date: '2014-12-24 23:12:00',
    //         name: i,
    //         upgradeNum: 'Upgraded: 56',
    //     });
    // }


    export default {
        name:'test',
        data() {
            return {
                figures,
                columns,
                innerColumns,
                selectedRowKeys: [], // Check here to configure the default column
                purchasingNum:'',
                quotation:[],
            };
        },
        methods:{
            onSelectChange(selectedRowKeys,record) {
                // console.log('selectedRowKeys changed: ', selectedRowKeys);
                this.selectedRowKeys = selectedRowKeys;
                this.quotation = record;
                console.log(this.quotation);
            },
            change(record){
                this.purchasingNum = record;
                console.log(this.purchasingNum);
            }
        },

    };
</script>
